package com.gxa.modules.app.outpatient.onlinereturn.service.impl;


import com.gxa.common.utils.Result;
import com.gxa.modules.app.outpatient.onlinereturn.mapper.OnlienReturnMapper;
import com.gxa.modules.app.outpatient.onlinereturn.service.OnlienReturnService;
import com.gxa.modules.model.entity.fee.Patient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName PatientServiceImpl
 * @Description
 * @Author Mr.YUAN
 * @Date 2022/11/12 11:27
 */
@Service
public class OnlienReturnServiceImpl implements OnlienReturnService {

    @Autowired
    private OnlienReturnMapper onlienReturnMapper;

    @Override
    public Result returnMoney(double returnMoney, Integer id) {
//        String payPassword = onlienReturnMapper.getByUserId(userId);
        double cardBalance = onlienReturnMapper.getMondyById(id);
        double lastMoney = cardBalance - returnMoney;

        if (returnMoney>cardBalance) {
            return new Result().error("退款失败");
        }
        onlienReturnMapper.updatemoney(lastMoney, id);
        return new Result().ok();
    }
}